// packageE/solitaire/components/yz_goodsPopup/yz_goodsPopup.js
// var app = getApp();
var specsMy = require("../../../mybehaviors/specs");
Component({
  behaviors: [specsMy],
  /**
	 * 组件的属性列表
	 */
  properties: {
    show:{
      value:false,
      type:Boolean
    },
    addCartBtn:{
      value:true,
      type:Boolean
    },
    goodsInfo:{
      value:{},
      type:Object
    },
    isScanCode:{
      value:false,
      type:Boolean
    },
  },

  /**
	 * 组件的初始数据
	 */
  data: {
    language:{},
    getMarketPrice:'',
    timeData:{},
    themeColor:'#f14e4e'
  },
  observers:{
    'show':function(showA){
      if(showA){
        console.log('组件')
        this.thisSpecsSetData();
      }
    }
  },
  lifetimes: {
    attached(){
    },
    ready() {
      try {			
        wx.getStorage({
          key:'langIndex',
          success:(res) => {
            console.log(res.data,888);
            this.setData({ 'language': res.data.en});
          }
        });
        wx.getStorage({
          key: 'yz_basic_info',
          success:  (res) => {
            this.setData({
              themeColor:res.data.theme_color,
              getMarketPrice: res.data.lang.goods && res.data.lang.goods.market_price?res.data.lang.goods.market_price:'',
              getprice: res.data.lang.goods && res.data.lang.goods.price?res.data.lang.goods.price:''
            });
          }
        });
      }
      catch(e){
        console.log(e);
      }
    }
  },
	
  /**
	* 组件的方法列表
	*/
  methods: {
    closeCart(){
      // 到预下单页
      this.triggerEvent('toOrderChild')
    },
    thisSpecsSetData(){
      let language = wx.getStorageSync('langIndex');
      this.setData({
        'language': language.en,
        specsManage: [],
        optionsId: 0,
        goodsCount:1
      });
      if(this.data.isScanCode){
        setTimeout(() => {
          this.initPopView();
        }, 100);
      }
    },
    storeAddCart(){
      this.triggerEvent('addCart',{ goodsInfo:this.data.goodsInfo,optionsId:this.data.optionsId,goodsCount:this.data.goodsCount });
    },
    goodsCountBlur(e){
      this.setData({
        goodsCount:Number(e.detail.value)
      })
    },
    popupSpecsbtn(evt){
      console.log(evt);
      this.triggerEvent("closeShow")
      this.setData({show:false});
    },
    onChangeTime(e){
      this.setData({
        timeData: e.detail,
      });
    },
    addCart(){
      this.triggerEvent('addCart',this.data.goodsInfo);
    }
  }
});















